#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "chartform.h"
#include<QtSerialPort/QSerialPort>
#include<QtSerialPort/QSerialPortInfo>
#include <QTimer>
#include "tempreture_controller.h"
#include <QStandardItemModel>
#include <QStandardItem>


QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void initPLCTable();



private slots:
    void refreshPort();
    void connectToPort();
    void enableToController();
    void clearChart();
    void saveChart();

    void getTempretrue();

    void enableControlType(const int i ){currentControlType=i;};
    void setPower();
    void setTempreture();
    void setCurve();

    void savedetailsToPlc();
    void uploadDetailsFromPlc();

    void openATClicked(bool clicked);


    void on_setPower_clicked();

    void on_setTemp_clicked();

    void on_setCurve_clicked();

private:
    Ui::MainWindow *ui;
    chartForm *chart = new chartForm;

    QTimer *ATTimer = new QTimer;
    QTimer *detectTimer = new QTimer();

    QSerialPort *myPort = new QSerialPort;
    Tempreture_Controller *controller = new Tempreture_Controller;

    QStandardItemModel *tableModel = new QStandardItemModel(this);
    QStandardItemModel *plctableModel = new QStandardItemModel(this);

    int currentControlType=0;
    float startTime = 0;

    float powerConversition = 1;

signals:
    void updateProgressBar(int value);
    void updatePortName(const QString item);
    void ATSucessful();
};
#endif // MAINWINDOW_H
